<template>
    <view class="page">
        <view class="news-main" v-if="dataInfo.id">
            <text class="title">{{ dataInfo.title }}</text>
            <text class="time">{{ dataInfo.create_time }}</text>
            <view class="content">
                <rich-text :nodes="dataInfo.content" class="rich-text"></rich-text>
                <label @click="openPage" class="look" v-if="dataInfo.type == 3">
                    查看详情
                </label>
                <view class="device-info">
                    <view class="device" @click="onClickDevice(dataInfo)">
                        点击查看设备详情
                    </view>
                </view>
            </view>
        </view>
        <Message ref="message"></Message>
    </view>
</template>
<script>
import { putRead } from "@/common/api/notice";
import detailModule from "@/common/mixins/detail-module";
export default {
    mixins: [detailModule],
    data() {
        return {
            mixinViewOptions: {
                getURL: "/getMessageDetail",
                isShowLoading: false,
                reachBottom: false,
                createdIsNeed: false,
                pullDown: true,
            },
        };
    },
    async onLoad(q) {
        let data = q.data || "";
        data = decodeURIComponent(data);
        if (!q.id) {
            return this.showModal({
                title: "提示",
                content: "非法参数,点击返回上一页",
                showCancel: false,
                success: (r) => {
                    this.$Router.go(-1);
                },
            });
        }
        if (data.type == "") { }
        this.dataForm.id = q.id;
        this.getDataInfo();
  },
  methods: {
    fetchComplete(err, data) {
        if (err) return this.message.error(res.message || "获取消息详情失败");
        if (!data.is_read) {
            putRead({
                id: data.id,
            });
        }
    },
    openPage() {
      let path = "";
      let data = this.dataInfo;
      if (data.type == 3) {
		console.log(data,"data.service_list.id??")
        path = "/pages/service-order-detail/service-order-detail";
        return this.$Router.push({
          path,
          query: {
            id: data.service_list[0].id,
          },
        });
      } else if (data.type == 2) {
        path = "/pageA/equipment-detail/index";
        let device_info = data.device_info;
        return this.$Router.push({
          path,
          query: {
            id: data.service_list.id,
          },
        });
      }
    },
        onClickDevice(info) {
            this.$Router.push({
                path: "/pageA/equipment-detail/index",
                query: {
                    device_id:info.device_id
                },
            });
        },
    },
};
</script>

<style lang="stylus" scoped>
@import '~@/common/stylus/variable';

page, .page {
  min-height: calc(100vh - var(--window-top));
  background: linear-gradient(180deg, #0D1523 0%, #102945 100%);
}

.device {
  text-decoration: underline;
  color: color-white;

  &-info {
    margin-top: 30rpx;

    .title {
      font-weight: 400 !important;
      font-size: 30rpx !important;
      text-align: left !important;
      padding: 0 !important;
    }
  }
}

.rich-text {
  word-break: break-all;
}

.news-main {
  padding-top: 40rpx;
  color: #fff;
  .title {
    display: block;
    text-align: center;
    font-size: 34rpx;
    line-height: 60rpx;
    color: #fff;
    font-weight: 700;
    padding: 0 30rpx;
  }

  .time {
    display: block;
    text-align: center;
    font-size: 28rpx;
    color: color-white;
    margin-top: 12rpx;
  }

  .content {
    display: block;
    padding: 30rpx;
    padding-top: 30rpx;
    line-height: 50rpx;
  }

  .look {
    text-decoration: underline;
  }
}
</style>